home *** CD-ROM | disk | FTP | other *** search
- /*
- File: SamplePartUtils.h
-
- Contains: SamplePart utility functions & classes
-
- Written by: Adapted from SamplePartUtils.cpp and enhanced by Dave Stafford.
-
- Copyright: © 1994,95 by Apple Computer, Inc., all rights reserved.
- */
-
-
- #ifndef _DRAWPARTPARTUTILS_
- #define _DRAWPARTPARTUTILS_
-
- #ifndef _SAMPLECOLLECTIONS_
- #include "SampleCollections.h"
- #endif
-
- // --- OpenDoc Includes ---
-
- #ifndef _ODTYPES_
- #include <ODTypes.h>
- #endif
-
- #ifndef SOM_ODFacet_xh
- #include <Facet.xh>
- #endif
-
- #ifndef SOM_ODShape_xh
- #include <Shape.xh>
- #endif
-
- #ifndef SOM_ODStorageUnitView_xh
- #include <SUView.xh>
- #endif
-
- #ifndef SOM_ODWindow_xh
- #include <Window.xh>
- #endif
-
- // --- OpenDoc Public Utilities ---
-
- #ifndef _ITEXT_
- #include <IText.h>
- #endif
-
- // --- Macintosh Includes ---
-
- #ifndef __TYPES__
- #include <Types.h>
- #endif
-
-
- //------------------------------------------------------------------------------
- // DrawEditor Specific Macros
- //------------------------------------------------------------------------------
- #define UNUSED(x) ((void) &x)
-
- //------------------------------------------------------------------------------
- // DrawEditor Specific Utilities
- //------------------------------------------------------------------------------
-
- // --- Misc
- void SetMenuItemText( Environment* ev, ODID menuID, ODID menuItem );
- ODSShort StrToShort( StringPtr pstr );
- void NumToString( ODSShort number, char* result );
- ODBoolean RectContainsRect(Rect& rect, Rect& inside);
-
- // --- Shapes
- ODBoolean IsValidRect( Rect& rect );
- void SortRect( Rect* rect );
- void MapRect( Rect& src1, Rect& src2, Rect* dest );
- void InspectShape( Environment* ev, ODShape* shape );
-
- // --- Imaging
- void ChangeFacetHighlight(Environment* ev,
- ODFacet* changeFacet,
- ODHighlight newHighlight);
-
- // --- D&D
- void HiliteFacet( Environment* ev, ODDragAndDrop* dad,
- ODFacet* facet, ODBoolean show);
-
- // --- Interchange
- ODBoolean ValueOnClipboard(Environment *ev, ODValueType type,
- ODSession* session);
- void ResolveClipboardPromises(Environment *ev, ODSession* session);
- void CheckAndResolvePromisedShapes(Environment *ev,
- COrderedList* shapeList,
- ODSession* session);
-
- // --- Resources
- PicHandle ODLoadPicture(ODSShort id);
- void ODDeletePicture(PicHandle thePicture);
-
- //------------------------------------------------------------------------------
- // StorageUnit I/O
- //------------------------------------------------------------------------------
-
- void StorageUnitSetISOStrValue( ODStorageUnit* su,
- Environment* ev,
- ODISOStr value);
-
- ODISOStr StorageUnitGetISOStrValue( ODStorageUnit* su,
- Environment* ev);
-
-
- //------------------------------------------------------------------------------
- // Function Prototypes
- //------------------------------------------------------------------------------
-
- void SetPartName(Environment* ev, ODPart* part, ODIText* partName);
- void GetEditorScriptLanguage(Environment* ev, ODScriptCode* script,
- ODLangCode* language);
- void FixedToIntRect(ODRect& fixedRect, Rect& intRect);
- void IntToFixedRect(Rect& intRect, ODRect& fixedRect);
- void LoadIcons(Environment* ev, ODUShort whichSuite, Handle* suite);
- void LoadThumbnail(Environment* ev, Handle* thumbnail);
- Rect TilePartWindow(Environment* ev, Rect* facetBounds,
- Rect* partWindowBounds);
- ODUShort CountFramesFacets(Environment* ev, ODFrame* frame);
-
- //------------------------------------------------------------------------------
- // Utility Class Definitions
- //------------------------------------------------------------------------------
-
- class CCloneInfo
- {
- public:
- CCloneInfo(ODDraftKey key,
- ODDraft* fromDraft,
- ODFrame* scopeFrame,
- ODCloneKind kind );
- ~CCloneInfo();
-
- // Key returned from draft when clone is initiated, it is used when
- // referencing the cloning operation
- ODDraftKey fKey;
-
- // Source of clone
- ODDraft* fFromDraft;
-
- // This is the containing scope of the clone operation
- // could be either destination or source.
- ODFrame* fScopeFrame;
-
- // The type of clone operation, specified at time of clone
- // and used by OpenDoc
- ODCloneKind fCloneKind;
-
- };
-
- class CFrameInfo
- {
- public:
- CFrameInfo();
- ~CFrameInfo();
-
- void Externalize(Environment* ev, ODStorageUnitView* storageUnitView);
- void CleanseFrameInfoProperty(Environment* ev, ODStorageUnit* storageUnit);
- void ExternalizeFrameInfo(Environment* ev, ODStorageUnit* storageUnit,
- ODDraftKey key, ODFrame* scopeFrame);
- void CloneInto(Environment *ev, ODDraftKey key,
- ODStorageUnitView* storageUnitView,
- ODFrame* scopeFrame);
- void InitFromStorage(Environment* ev, ODStorageUnitView* storageUnitView);
-
- ODBoolean IsFrameActive();
- void SetFrameActive(ODBoolean active);
- ODBoolean FrameNeedsReactivating();
- void SetFrameReactivate(ODBoolean reactivate);
- ODFacet* GetActiveFacet();
- void SetActiveFacet(ODFacet* facet);
- void SetSourceFrame(Environment* ev, ODFrame* sourceFrame);
- ODFrame* GetSourceFrame();
- void ReleaseSourceFrame(Environment* ev);
- ODBoolean HasSourceFrame();
- ODWindow* GetPartWindow();
- ODBoolean HasPartWindow();
- void SetPartWindow(ODWindow* window);
- void AttachFrame(Environment* ev, ODFrame* frame);
- void DetachFrame(Environment* ev);
- ODFrame* GetAttachedFrame();
- ODBoolean HasAttachedFrame();
- void SetShouldDisposeWindow(ODBoolean should);
- ODBoolean ShouldDisposeWindow();
-
- private:
-
- ODBoolean fFrameActive;
- ODBoolean fFrameReactivate;
- ODBoolean fShouldDisposeWindow;
- ODFacet* fActiveFacet;
- ODFrame* fSourceFrame;
- ODFrame* fAttachedFrame;
- ODWindow* fPartWindow;
- };
-
-
-
-
- //-------------------------------------------------------------------------
- // Inline methods
- //-------------------------------------------------------------------------
-
- //=========================================================================
- // CFrameInfo
- //=========================================================================
-
- inline ODBoolean CFrameInfo::IsFrameActive()
- {
- return fFrameActive;
- }
-
- inline void CFrameInfo::SetFrameActive(ODBoolean active)
- {
- fFrameActive = active;
- }
-
- inline ODBoolean CFrameInfo::FrameNeedsReactivating()
- {
- return fFrameReactivate;
- }
-
- inline void CFrameInfo::SetFrameReactivate(ODBoolean reactivate)
- {
- fFrameReactivate = reactivate;
- }
-
- inline ODFacet* CFrameInfo::GetActiveFacet()
- {
- return fActiveFacet;
- }
-
- inline void CFrameInfo::SetActiveFacet(ODFacet* facet)
- {
- fActiveFacet = facet;
- }
-
- inline ODFrame* CFrameInfo::GetSourceFrame()
- {
- return fSourceFrame;
- }
-
- inline ODBoolean CFrameInfo::HasSourceFrame()
- {
- return (fSourceFrame != kODNULL);
- }
-
- inline ODWindow* CFrameInfo::GetPartWindow()
- {
- return fPartWindow;
- }
-
- inline ODBoolean CFrameInfo::HasPartWindow()
- {
- return (fPartWindow != kODNULL);
- }
-
- inline void CFrameInfo::SetPartWindow(ODWindow* window)
- {
- fPartWindow = window;
- }
-
- inline ODFrame* CFrameInfo::GetAttachedFrame()
- {
- return fAttachedFrame;
- }
-
- inline ODBoolean CFrameInfo::HasAttachedFrame()
- {
- return (fAttachedFrame != kODNULL);
- }
-
- inline void CFrameInfo::SetShouldDisposeWindow(ODBoolean should)
- {
- fShouldDisposeWindow = should;
- }
-
- inline ODBoolean CFrameInfo::ShouldDisposeWindow()
- {
- return fShouldDisposeWindow;
- }
-
- #endif
-
-